package io.renren.modules.jxgkphone.dao;


import io.renren.modules.jxgkphone.entity.EvaluationContent;
import io.renren.modules.jxgkphone.entity.EvaluationLevel;
import io.renren.modules.jxgkphone.entity.EvaluationType;
import io.renren.modules.jxgkphone.entity.TeachingEvaluation;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
余沛然，教学评价
 */
@Repository
@Mapper
public interface TeachingEvaluationMapper {
    @Insert("INSERT INTO teaching_evaluation(teacher_id,student_id,evaluation_content,evaluation_time,evaluation_id,course_id)" +
            "VALUES(#{teacherId}, #{studentId},#{evaluationContent}, #{evaluationTime}, #{evaluationId},#{courseId})")
    void InsertTeachingEvaluation(TeachingEvaluation te);

    @Select("SELECT * FROM evaluation_content")
    List<EvaluationContent> findAllEvaluationContent();
    @Select("SELECT * FROM evaluation_content WHERE evaluation_content_id=#{ecid}")
    EvaluationContent findEvaluationContentById(String ecid);

    //目前仅存在学生评价老师
    @Select("SELECT * FROM evaluation_type WHERE evaluation_type_user= 'teacher'")
    List<EvaluationType> findAllEvaluationType();

    @Select("SELECT * FROM evaluation_level")
    List<EvaluationLevel> findAllEvaluationLevel();

    @Select("SELECT *  FROM teaching_evaluation WHERE " +
            "teacher_id=#{teacher_id} AND " +
            "student_id=#{student_id} AND " +
            "course_id=#{course_id}")
    List<TeachingEvaluation> findEvaluationInfo(@Param("teacher_id")String teacher_id,
                                                @Param("student_id")String student_id,
                                                @Param("course_id")String course_id);
    @Delete("DELETE FROM teaching_evaluation WHERE " +
            "teacher_id=#{teacher_id} AND " +
            "student_id=#{student_id} AND " +
            "course_id=#{course_id}")
    void deleteEvaluationInfo(@Param("teacher_id")String teacher_id,
                                                @Param("student_id")String student_id,
                                                @Param("course_id")String course_id);
}